#ifndef _DIRECTORY_H
#define _DIRECTORY_H

#include <stdint.h>
#include <bitset>
#include <vector>

#define MAX_THREADS     1024

class Directory {
        std::vector< std::bitset<MAX_THREADS> > _info;
        uint32_t _pages;
    public:
        Directory():_info(1),_pages(1){}
        Directory(uint32_t pages):_info(pages),
                _pages(pages) { }
        ~Directory(){}
        inline void set(uint32_t thread) {_info[0].set(thread,1);}
        inline void set(uint32_t thread,uint32_t page) {_info[page].set(thread,1);}
        inline bool get(uint32_t thread,uint32_t page) {return _info[page].test(thread);}
        inline void reset(uint32_t thread) {_info[0].reset(thread);}
        inline void reset(uint32_t thread,uint32_t page) {_info[page].reset(thread);}
        void reset(){
                for(int i=0;i<_pages;i++)
                    _info[i].reset();
        }
        inline uint32_t count(uint32_t page) { return _info[page].count();}
        uint32_t count() const {
                uint32_t sum=0;
                for(int i=0;i<_pages;i++)
                        sum+=_info[i].count();
                return sum;
        }
};

#endif
